Add Phi-4-mini-instruct support (MIT, 3.8B) - #75
Closed
stikves wants to merge 1 commit into
Closed
Conversation
Microsoft Phi-4-mini for on-device inference. MIT licensed, strong quality for its size (reasoning, coding, math). Architecture: - model_type: phi3 (shared across Phi-3/3.5/4-mini) - 32 layers, 3072 hidden, 24 heads / 8 KV heads, head_dim=128 - Partial rotary embedding (75% of head_dim = 96 dims) - Fused gate_up_proj split at export time - Longrope attention_factor (1.19) for extended context - tie_word_embeddings (lm_head = embed_tokens) Performance (Apple Silicon): - INT4: ~253 t/s prefill, ~108 t/s generation (~2GB) - FP16: ~32 t/s prefill, ~38 t/s generation (~7.6GB) Default preset uses INT4 quantization for best on-device experience.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Microsoft Phi-4-mini-instruct for on-device inference. MIT licensed, 3.8B parameters, strong quality for reasoning, coding, and math tasks.
Changes
python/src/coreai_models/models/macos/phi3.py— New model class (Phi-3/4-mini architecture)phi3model_type)phi-4-mini-instructdefaulting to INT4 quantizationmodels/phi4/README.md— Usage documentationArchitecture
phi3(shared across Phi-3, 3.5, 4-mini)gate_up_projsplit at export time to reuse standard MLP primitiveattention_factorfor extended context supporttie_word_embeddings(lm_head shares embed_tokens weight)Performance (Apple Silicon)
Export
Test plan